/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.edu.unmsm.fisi.ceiecbt.app.servlets;

import java.io.*;
import java.net.*;

import java.util.List;
import javax.ejb.EJB;
import javax.servlet.*;
import javax.servlet.http.*;

import pe.edu.unmsm.fisi.ceiecbt.ejb.entidad.ComtbEmpresa;
import pe.edu.unmsm.fisi.ceiecbt.ejb.beans.ComtbEmpresaFacadeRemote;
import pe.edu.unmsm.fisi.ceiecbt.ejb.beans.ComtbIndicadoresFacade;
import pe.edu.unmsm.fisi.ceiecbt.ejb.beans.ComtbIndicadoresFacadeRemote;
import pe.edu.unmsm.fisi.ceiecbt.ejb.entidad.ComtbIndicadores;

/**
 *
 * @author Liz Alvarez
 */
public class Empresa extends HttpServlet {
    @EJB
      private ComtbEmpresaFacadeRemote combtemp;
    
     @EJB
      private ComtbIndicadoresFacadeRemote combtind;
    /** 
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        
            
            int op=Integer.parseInt(request.getParameter("operacion"));
            
            int id=Integer.parseInt(request.getParameter("id"));
        
            switch (op) {
            case 0 :
                //Ver detalle de empresa general
                List<ComtbEmpresa> objp=combtemp.findByID(id);
                request.setAttribute("ObjEmpresa",objp);
                request.getRequestDispatcher("verDetalleEmp.jsp").forward(request, response);
                    break;
            
                  case 1 :
                //Ver detalle de empresa general
                List<ComtbIndicadores> objp1=combtind.findByEmprevCodEmpresa(id);
                request.setAttribute("ObjIndicador",objp1);
                
                List<ComtbEmpresa> objp2=combtemp.findByID(id);
                request.setAttribute("ObjEmpresa",objp2);
                
                request.getRequestDispatcher("verDetalleEmp.jsp").forward(request, response);
                    break;
                    
                    
                }
        
        
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
    * Returns a short description of the servlet.
    */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>
}
